package com.wft.面试题;

import java.io.*;

public class 合并两个文件 {
    public static void main(String[] args) throws Exception {
        BufferedReader reader1 = new BufferedReader(new FileReader(new File("D:\\git\\design-pattern\\src\\main\\java\\com\\wft\\面试题\\finallyAndResturn.java")));
        BufferedReader reader2 = new BufferedReader(new FileReader(new File("D:\\git\\design-pattern\\src\\main\\java\\com\\wft\\面试题\\finallyAndResturn.java")));
        BufferedWriter writer = new BufferedWriter(new FileWriter(new File("D:\\git\\design-pattern\\src\\main\\java\\com\\wft\\面试题\\1.txt")));
        String str1 = reader1.readLine();
        String str2 = reader2.readLine();
        while (str1 != null || str2 != null) {
            if (str1 != null) {
                writer.write(str1);
                writer.newLine();
                str1 = reader1.readLine();
            }
            if (str2 != null) {
                writer.write(str2);
                writer.newLine();
                str2 = reader2.readLine();
            }
        }
        writer.flush();
    }
}
